<?php

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use App\Models\Service;
use Illuminate\Http\Request;
use App\Models\Category;
class ServiceController extends Controller
{
    
    public function index(Request $request)
    {
        //获取当前栏目
        $this->__cate_init__($request);
        $category = $this->category;
        
        //判断栏目跳转
        $redirect = $this->isLastRedirect();
        if($redirect)return $redirect;
        
        
        $where = ['status' => 1,'type'=> $request->catid];
        
        $pageList = Service::where($where)->orderBy('id', 'desc')->paginate(15);
        $pageList->everypage = 15;
        $pageList->appends(['catid'=> $request->catid]);
        
        
        return view('service.index', compact('pageList', 'category'));
    }
    
    public function detail(Request $request)
    {
        $info = Service::findOrFail($request->id);
        
        
        return $info;
    }
}


